package contorler;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import service.LoginService;

@Controller
public class LoginController {
	@Autowired
	private LoginService loginService;

	// 用于访问登陆页面
	@RequestMapping("/login")
	public String login() {
		return "jsp/login";
	}

	// 用于接收用户表单提交请求
	@RequestMapping("/submit")
	@ResponseBody
	public String login_submit(String username, String password) {
		boolean result = loginService.execute(username, password);
		if (result) {
			return "登录成功";
			// return "jsp/login_succ";
		} else {
			return "登录失败";
			// return "jsp/login_fail";
		}
	}
}
